﻿Imports extranet.BC
Imports extranet.BE
Imports extranet.DA


Partial Class noticias_administrarNoticias
  Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
      Me.grvNoticias.DataSource = BCNoticia.Listar()
      grvNoticias.DataBind()
    End If
  End Sub

  Protected Sub addNoticia_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles addNoticia.Click
    Response.Redirect("salvarNoticia.aspx")
  End Sub

  Protected Sub grvNoticias_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grvNoticias.RowEditing
    Response.Redirect("salvarNoticia.aspx?idNoticia=" & grvNoticias.DataKeys(e.NewEditIndex).Value.ToString())
  End Sub

  Protected Sub grvNoticias_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles grvNoticias.RowDeleting
    Response.Redirect("apagarNoticia.aspx?idNoticia=" & grvNoticias.DataKeys(e.RowIndex).Value.ToString())
  End Sub

  Sub grvNoticias_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
    If e.CommandName = "Ativar" Then
      Response.Redirect("desativarNoticia.aspx?idNoticia=" & e.CommandArgument)
    End If
  End Sub

End Class
